/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: YCKOKO
 * Date: 2022-10-13
 * Time: 14:19
 */

class Student{
    String name;
    int age;

    void read(){
        System.out.println("你好！我叫"+name+",今年"+age);
    }
}

public class demo2 {
    public static void main(String[] args) {

    }

    //对象引用传递
    public static void main2(String[] args) {
        Student stu1 = null;
        Student stu2 = new Student();
        stu1 = stu2;
        stu1.name = "小杨";
        stu2.age = 18;
        stu1.read();
        stu2.read();
    }

    //对象的创建及使用
    public static void main1(String[] args) {
        Student stu1 = new Student();
        stu1.name = "小杨";
        stu1.age = 19;
        stu1.read();
        stu1.name = "小王";
        stu1.read();
    }

}
